﻿@model SmallJob.Model.Category
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var isadd = Convert.ToBoolean(ViewData["isadd"]);
    var listCate = ViewData["AllCate"] as SelectList;
    var pcate = isadd ? 0 : Model.ParentID;
}

@using (Html.BeginForm("Save", "Category", FormMethod.Post, new { id = "form-category" }))
{
    
    <input type="hidden" name="id" value="@(isadd ? 0 : Model.ID)" />
    @Html.ValidationSummary()
    <fieldset>
        <legend>Banner</legend>
        @if (Convert.ToBoolean(ViewData["isok"]))
        {
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                Commit Success
            </div>
        }
        <label>Name*</label>
        <input type="text" name="name" value="@(isadd ? "" : Model.Name)"/>
        @*@Html.DropDownList("parentcateid", listCate)*@
        @*@Html.DropDownListFor(model => model.ParentID,listCate)*@
        @*<select name="parentcateid">
            <option value="0" selected="@(0==pcate?"selected":"")">None</option>
            @foreach (var item in listCate)
            {
                <option value="@item.ID" selected="@(item.ID==pcate?"selected":"")">@item.Name</option>
            }
        </select>*@
        <p>
            <input type="submit" value="@(isadd ? "Create" : "Edit")" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
